<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">
		<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
		<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../../../JS/common.js"></script>
		<script type="text/javascript" src="../../../JS/SHA-1.js"></script>
		<script type="text/javascript" src="../../../JS/BasicInfomation.js"></script>
	</head>

	<body style="padding: 0px;">
		<div class="easyui-layout" style="width:100%;height:600px;">
			<div id="div_search" data-options="region:'north'" style="height:90px;">
				
			</div>
			<div data-options="region:'center'">
				<div>
					<table id="dg" style="width: 100%;" class="table_style">
					</table>
				</div>
			</div>
		</div>
		<div id="toolbar"></div>
		<div id="dlg" class="easyui-dialog" closed="true" style="width:600px;height:300px;padding:10px">
			<iframe id="ifrmEdit" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>
		</div>
		<script src="../../../JS/LogisticsShareFunction/BasicInfomationSearchFunction.js"></script>
	</body>
	<script>
		var searchType = SEARCH_INTERNAL_NAME + SEARCH_ORIGINAL_NAME+SEARCH_CUSTOMER_TYPE;
		var searchContent = buildSearchOptions(searchType,"");
		$("#div_search").append(searchContent);
		var currid = getID();
		var content = "";
		var AddDialog;
		content = AddToolBar(23 + TOOLBAR_REDO);
		$("#toolbar").append(content);

		var DialogHeight = 300;
		var DialogWidth = 400;

		function newdata() {
			var pLocation = "UI/LOGISTICS/BasicInformation/BasicInformationConvertTableAdd.html?id=-1";
			$("#ifrmEdit").attr("src", pLocation);
			constructDialog($("#dlg"), "新增", DialogWidth, DialogHeight);
			AddDialog.dialog('open');
		}
		
		function redodata(){
			checkAllData("/logistics/converttable/list.do");
		}

		function editdata() {
			var pLocation = '';
			var row = $('#dg').datagrid('getSelected');
			if(!row) {
				$.messager.alert('Info', "请选择你需要修改数据");
				return;
			}
			pLocation = "UI/LOGISTICS/BasicInformation/BasicInformationConvertTableAdd.html?id=" + row.ID;
			$("#ifrmEdit").attr("src", pLocation);
			constructDialog($("#dlg"), "修改", DialogWidth, DialogHeight);
			AddDialog.dialog('open');
		}

		function destroy() {
			var row = $('#dg').datagrid('getSelected');
			if(row) {
				$.messager.confirm('Confirm', '是否删除', function(r) {
					if(r) {
						$.post(RemoteLinkAddress + "/logistics/converttable/delete.do", {
								ID: row.ID
							},
							function(result) {
								if(result.msg == "success") {
									$('#dg').datagrid('reload'); // reload the user data
									$.messager.alert({ // show error message
										title: '成功',
										msg: '删除成功'
									});
								} else {
									$.messager.alert({ // show error message
										title: 'Error',
										msg: result.msg
									});
								}
							},
							'json');
						$('#dg').datagrid('reload');
					}
				});
			}
		}

		$('#dg').datagrid({
			url: RemoteLinkAddress + '/logistics/converttable/list.do',
			toolbar: '#toolbar',
			method: 'get',
			pagination: 'true',
			fitColumns: 'false',
			rownumbers: 'true',
			singleSelect: 'true',
			height: 400,
			columns: [
				[{
					field: 'ID',
					title: 'ID',
					width: '0%',
					align: 'center'
				}, {
					field: 'CUSTOMER_TYPE',
					title: '用户组',
					width: '24%',
					align: 'center'
				}, {
					field: 'INTERNAL_NAME',
					title: '内部产品名称',
					width: '24%',
					align: 'center'
				}, {
					field: 'ORIGINAL_NAME',
					title: '原始产品名称',
					width: '24%',
					align: 'center'
				}, {
					field: 'ORIGINAL_UNIT',
					title: '原始计量单位',
					width: '24%',
					align: 'center'
				}]
			],
			onDblClickRow: function(index, row) {
				pLocation = "UI/LOGISTICS/BasicInformation/BasicInformationConvertTableAdd.html?id=" + row.ID;
				$("#ifrmEdit").attr("src", pLocation);
				constructDialog($("#dlg"), "修改", DialogWidth, DialogHeight);
				AddDialog.dialog('open');
			}
		});
		$('#dg').datagrid('hideColumn', 'ID');
		
		function dialogClose() {
			AddDialog.dialog('close');
		}

		function doSearch() {
			var searchCondition = "";
			var _url = "";
			searchCondition = processSearchCondition();
			_url = RemoteLinkAddress + '/logistics/converttable/list.do?' + searchCondition;
			$('#dg').datagrid('reload', _url);
		}

		
		
		function loaddata() {
			$.messager.confirm('Confirm', '是否导出', function(r) {
				if(r) {
					$.post(RemoteLinkAddress + "/logistics/converttable/excel.do", {
							USER_ID: 'admin'
						},
						function(result) {
							if(result.msg == "success") {
								_downloadpath = result.path;
								_pathTarget = "<a class=\'download\' href=\'" + _downloadpath + "\' target='_blank'>点击下载</a>";
								$.messager.alert({ // show error message
									title: '成功',
									msg: _pathTarget
								});
							} else {
								$.messager.alert({ // show error message
									title: 'Error',
									msg: result.msg
								});
							}
						},
						'json');
				}
			});
		}
	</script>

</html>